import { createRouter, createWebHistory } from 'vue-router'

const layout = () => import('@/views/layout/index.vue')
const home = () => import('@/views/layout/home.vue')
const category = () => import('@/views/layout/category.vue')
const cart = () => import('@/views/layout/cart.vue')
const user = () => import('@/views/layout/user.vue')

const login = () => import('@/views/login.vue')
const search = () => import('@/views/search.vue')
const list = () => import('@/views/list.vue')
const detail = () => import('@/views/detail.vue')
const comment = () => import('@/views/comment.vue')

const checkout = () => import('@/views/checkout.vue')
const address = () => import('@/views/address.vue')
const addressCreate = () => import('@/views/addressCreate.vue')
const addressUpdate = () => import('@/views/addressUpdate.vue')

const order = () => import('@/views/order.vue')
const myCoupon = () => import('@/views/myCoupon.vue')
const coupon = () => import('@/views/coupon.vue')
const oderDetail = () => import('@/views/oderDetail.vue')

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: layout,
      redirect: '/home',
      children: [
        {
          path: '/home',
          component: home
        },
        {
          path: '/category',
          component: category
        },
        {
          path: '/cart',
          component: cart
        },
        {
          path: '/user',
          component: user
        }
      ]
    },
    {
      path: '/login',
      component: login
    },
    {
      path: '/search',
      component: search
    },
    {
      path: '/list',
      component: list
    },
    {
      path: '/detail',
      component: detail
    },
    {
      path: '/comment',
      component: comment
    },
    {
      path: '/checkout',
      component: checkout
    },
    {
      path: '/address',
      component: address
    },
    {
      path: '/address/create',
      component: addressCreate
    },
    {
      path: '/address/update',
      component: addressUpdate
    },
    {
      path: '/order',
      component: order
    },
    {
      path: '/mycoupon',
      component: myCoupon
    },
    {
      path: '/coupon',
      component: coupon
    },
    {
      path: '/order/detail',
      component: oderDetail
    }
  ]
})

export default router
